// CKEventDisp.h : Declaration of the CCKEventDisp

#ifndef __CKEVENTDISP_H_
#define __CKEVENTDISP_H_

#pragma warning(disable: 4786)

#include "atlbase.h"

#include "exdisp.h"
/////////////////////////////////////////////////////////////////////////////
// CCKEventDisp
class CCKEventDisp : public DWebBrowserEvents2
{
public:
	CCKEventDisp():m_RefCount(0)
	{}
	virtual ~CCKEventDisp()
	{}
	STDMETHOD(QueryInterface)( 
		/* [in] */ REFIID riid,
		/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) 
	{ 
		if (riid == IID_IDispatch)
		{
			*ppvObject = dynamic_cast<IDispatch*>(this);
			
			if (*ppvObject)
			{
				AddRef();
				return S_OK; 
			}
		}

		return E_FAIL;
	};
        
    virtual ULONG STDMETHODCALLTYPE AddRef( void)
	{
		m_RefCount++;
		return m_RefCount;
	}
	  
	virtual ULONG STDMETHODCALLTYPE Release( void)
	{
		if (m_RefCount > 0)
			m_RefCount--;

		if (m_RefCount == 0)
			delete this;

		return m_RefCount;
	}

	STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
	{
		*pctinfo = 1;
		return E_NOTIMPL;
	}
	STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
	{
		return E_NOTIMPL; // _tih.GetTypeInfo(itinfo, lcid, pptinfo);
	}
	STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
		LCID lcid, DISPID* rgdispid)
	{
		return E_NOTIMPL; // _tih.GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid);
	}
	
	STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
		LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
		EXCEPINFO* pexcepinfo, UINT* puArgErr)
	{
		return E_NOTIMPL;
	};

// ICKEventDisp
protected:
	ULONG m_RefCount;
};

#endif //__CKEVENTDISP_H_
